#pragma once
#include <sstream>
#include <queue>
#include "Player.h"
#include "TextField.h"
#include "Pokemon.h"
#include "SDLScene.h"
#include "SDLEngine.h"
#include "SDLText.h"
#include "Animations.h"
#include "ScalingBar.h"

class CombatScene : public SDLScene
{
public:
	CombatScene(std::string _sceneID);
	~CombatScene();

private:
	std::stringstream m_MainOutput;
	std::queue<std::string> m_Outputs;

	TextField m_MainMenu;
	TextField m_AttackMenu;
	TextField m_ActionMenu;
	TextField m_AttackInfoMenu;
	
	SDLSprite* m_Bkg;
	SDLSprite* m_Cursor;

	ScalingBar* m_PlayerHpBar;
	ScalingBar* m_EnemyHpBar;
	ScalingBar* m_PlayerXpBar;

	Animations* m_EnemySprite;
	Animations* m_PlayerSprite;
	Animations* m_EnemyAttack;
	Animations* m_PlayerAttack;
	Animations* m_CurrentAnim;

	SDLAnimation* m_PokeballSprite;

	SDLText* m_BkgText;
	SDLText* m_PlayerName;
	SDLText* m_PlayerHP;
	SDLText* m_PlayerLevel;
	SDLText* m_EnemyName;
	SDLText* m_EnemyLevel;

	Player m_Player;
	Pokemon* m_CurrentPokemon;
	Pokemon m_Enemy;
	int m_EscapeCount;
	int m_AttackIndex;
	int m_EnemyAttackIndex;
	bool m_Proceed;
	GamePhase m_CurrentPhase;
	bool m_ChoiceMatrix[2][2];
	bool m_IsInitialized;
	bool m_Success;
	bool m_Caught;
	bool m_IsThrown;
	bool m_Again;

	void Update();
	void UpdateUI();
	void InitInterface();
	void InitPlayer();
	void InitEnemy();
	void CheckCursorMovement(int _offsetX, int _offsetY);
	void CheckCursorMovementAttack(int _offsetX, int _offsetY);
	std::string GetStringFromType(PokemonType _type) const;

	void DisplayAttackInfo();
	void DisplayPokemonAttacks();
	void GetNewEnemy();

	void SetChoiceMatrix(bool _flag)
	{
		m_ChoiceMatrix[0][0] = _flag;
		m_ChoiceMatrix[0][1] = _flag;
		m_ChoiceMatrix[1][0] = _flag;
		m_ChoiceMatrix[1][1] = _flag;
	}

	void CombatInitiation();
	void SelectAction();
	void SelectAttack();
	void FightSummary();
	void EndTurn();
	void Catch();
	void Run();
	void ForgetAttack();
	
	void PlayerStandBy();
	void PlayerAttack();
	void PlayerAttackRecap();

	void EnemyStandBy();
	void EnemyAttack();
	void EnemyAttackRecap();
};

